﻿<%@ Page Title="精美图库" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    Inherits="Wjtour.Web.Front.gallery" %>

<%@ Import Namespace="Wjtour.Domain" %>
<%@ Import Namespace="Wjtour.Common" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script language="javascript">
        $(document).ready(function () {
            $(document).click(function () {
                hideclass();
            });
            $(document).scroll(function () {
                hideclass();
            });
        });
        var showclass = (function () {
            $('.classdiv').animate({ height: 'show' });
        });
        var hideclass = (function () {
            $('.classdiv').animate({ height: 'hide' });
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
    <div class="ipage indexpage">
        <div class="bpath">当前位置：<a href="/">首页</a> &gt; 美图欣赏 &gt; 精美图库</div>
        <div class="imgbox">
            <h4>精美图库
				<span>
                    <img src="css/images/icon07.png" style="cursor: pointer;" onmouseover="showclass();" />
                    <div class="classdiv">
                        <img src="css/images/classtop.png" />
                        <div>
                            <a href="gallery.aspx?type=1">古韵吴江</a><br />
                            <a href="gallery.aspx?type=2">生态吴江</a><br />
                            <a href="gallery.aspx?type=3">多彩吴江</a><br />
                            <a href="gallery.aspx?type=4">乐居吴江</a>
                        </div>
                        <img src="css/images/classbottom.png" />
                    </div></h4>

            <div class="cols" id="waterfall">
                <%if (data != null && data.Datas.Count > 0)
                  {
                      foreach (var item in data.Datas)
                      {
                %>
                <div class="item">
                    <img src="<%=item.smallImg %>" /><a href="galleryshow.aspx?id=<%=item.galleryid %>" target="_blank"><%=item.galleryname??"" %></a>
                    <span class="ding"><a href="javascript:void(0)" data-imgid="<%=item.id %>">赞</a> <span class="num" data-imgid="<%=item.id %>"><%=item.zan %></span></span>
                </div>
                <%}
                  } %>
            </div>
            <div class="clear"></div>
        </div>

        <img alt="Top_arrow" id="top_arrow" class="top_arrow" src="css/images/top_arrow.png" style="display: block; cursor: pointer;">
        <script type="text/javascript" src="js/top_arrow.js?20121128"></script>

        <div class="loading">
            <img src="css/images/loading.gif"><span>正在加载...</span>
        </div>
        <div id="navigation">
            <a href="GetGalleryPictures.ashx?type=<%=type %>&page=1"></a>
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#waterfall').infinitescroll({
                navSelector: "#navigation", //导航的选择器，会被隐藏
                nextSelector: "#navigation a", //包含下一页链接的选择器
                itemSelector: ".item", //你将要取回的选项(内容块)
                debug: true, //启用调试信息
                animate: true, //当有新数据加载进来的时候，页面是否有动画效果，默认没有
                extraScrollPx: 150, //滚动条距离底部多少像素的时候开始加载，默认150
                bufferPx: 40, //载入信息的显示时间，时间越大，载入信息显示时间越短
                errorCallback: function () {
                    //alert('error
                    $(".loading").hide();
                }, //当出错的时候，比如404页面的时候执行的函数
                localMode: true, //是否允许载入具有相同函数的页面，默认为false
                dataType: 'html',
                loading: {
                    msgText: "加载中...",
                    finishedMsg: '没有新数据了...',
                    selector: '.loading' // 显示loading信息的div
                }

            }, function (newElems) {
                //程序执行完的回调函数
                var $newElems = $(newElems);
                $('#waterfall').append($newElems);
                var page = $("#navigation a").attr("href").split('=')[2];
                var nextpage = parseInt(page) + 1;
                $("#navigation a").attr("href", "GetGalleryPictures.ashx?type=<%=type %>&page=" + nextpage);
                setzan();
            });

            setzan();
        });

        function setzan() {
            $(".ding a").unbind("click").click(function () {
                var el = event.srcElement || event.target;
                var id = $(el).data("imgid");
                var cookieName = yourIp + "_gallery_" + id;
                var v = getCookieValue(cookieName)
                if (!!v) {
                    alert('您已赞过！');
                    return false;
                }
                $.ajax({
                    url: 'ZanHandler.ashx',
                    data: { 'type': 'pic', 'id': id },
                    dataType: 'json',
                    success: function (d) {
                        if (d.Errcode != "0") {
                            alert(d.Errmsg);
                        } else {
                            alert(d.Errmsg);
                            $(el).next().text(d.Data);
                            var cookieValue = 'true';
                            var cookieExpire = new Date().setDate(new Date().getDate() + 1);
                            setCookie(cookieName, cookieValue, cookieExpire);
                        }
                    },
                    error: function () {

                    }
                });
            });

            $("span .num").each(function () {
                var id = $(this).data("imgid");
                var cookieName = yourIp + "_gallery_" + id;
                var v = getCookieValue(cookieName)
                var zantext = $(this);
                if (!!v) {
                    $(this).removeClass("ding");
                    $(this).addClass("noding");
                    zantext = '您已赞过！';
                    $(this).text(zantext);
                }
            });
        }
    </script>
</asp:Content>

